Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Push and Pop Methods

You can call renderer push and pop methods whenever the graphics state in the view needs to be pushed or popped. Code may isolate the state by submitting a display group that pushes and pops or by making calls such as the following:

Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &red, view);
Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &blue, view);
Q3Attribute_Submit(kQ3AttributeTypeSpecularColor, &white, view);
Q3Box_Submit(&unitBox, view);
Q3TranslateTransform_Submit(&unitVector, view);
Q3Push_Submit(view);
Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &blue, view);
Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &green, view);
Q3Box_Submit(&unitBox, view);
Q3Pop_Submit(view);
Q3TranslateTransform_Submit(&unitVector, view);
Q3Box_Submit(&unitBox, view);

Even though you support RendererPush and RendererPop in your renderer, you must also maintain your drawing state as a stack. Your code will not automatically be updated with the popped state after RendererPop is called. If you do not support push and pop functionality in your renderer, you may maintain a single copy of the drawing state. Your code will be updated with changed fields after the view stack is popped.

A renderer that supports RendererPush and RendererPop will be called in the following sequence, based on the previous example:

RendererUpdateAttributeDiffuseColor(...,&red)
RendererUpdateAttributeTransparencyColor(...,&blue)
RendererUpdateAttributeSpecularColor(...,&white)
RendererUpdateMatrixLocalToWorld(...)
RendererSubmitGeometryBox(...)
RendererPush(...)
RendererUpdateAttributeDiffuseColor(...,&blue)
RendererUpdateAttributeTransparencyColor(...,&green)
RendererSubmitGeometryBox(...)
RendererPop(...)
RendererUpdateMatrixLocalToWorld(...)
RendererSubmitGeometryBox(...)

A renderer that does not support RendererPush and RendererPop will be called in the following sequence:

RendererUpdateAttributeDiffuseColor(...,&red)
RendererUpdateAttributeTransparencyColor(...,&blue)
RendererUpdateAttributeSpecularColor(...,&white)
RendererUpdateMatrixLocalToWorld(...)
RendererSubmitGeometryBox(...)
RendererUpdateAttributeDiffuseColor(...,&blue)
RendererUpdateAttributeTransparencyColor(...,&green)
RendererSubmitGeometryBox(...)
RendererUpdateAttributeDiffuseColor(...,&red)
RendererUpdateAttributeTransparencyColor(...,&blue)
RendererUpdateMatrixLocalToWorld(...)
RendererSubmitGeometryBox(...)

In both cases, update calls may be in a different order, as explained in "Renderer Methods" .

TQ3XRendererPushMethod

#define kQ3XMethodTypeRendererPush
                     Q3_METHOD_TYPE('r','d','p','s')
typedef TQ3Status (*TQ3XRendererPushMethod)(
                     TQ3ViewObject    view,
                     void             *rendererPrivate);
view
The current view being rendered to.
rendererPrivate
A pointer to structure of size instanceSize , passed into Q3ObjectHierarchy_RegisterClass , and initialized in your kQ3MethodTypeObjectNew method.

DESCRIPTION

The kQ3XMethodTypeRendererPush method type returns a function pointer of type TQ3XRendererPushMethod.

TQ3XRendererPopMethod

#define kQ3XMethodTypeRendererPop
                     Q3_METHOD_TYPE('r','d','p','o')
typedef TQ3Status (*TQ3XRendererPopMethod)(
                     TQ3ViewObject    view,
                     void             *rendererPrivate);
view
The current view being rendered to.
rendererPrivate
A pointer to structure of size instanceSize , passed into Q3ObjectHierarchy_RegisterClass , and initialized in your kQ3MethodTypeObjectNew method.

DESCRIPTION

The kQ3XMethodTypeRendererPop method type returns a function pointer of type TQ3XRendererPopMethod.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |